home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000107_icon-group-sender _Wed Apr 9 15:06:07 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Thu, 10 Apr 1997 12:33:56 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA00534; Thu, 10 Apr 1997 12:33:56 -0700
  4. Sender: rpereda@micro.ti.com
  5. Message-Id: <334BF6AF.485EBC12@micro.ti.com>
  6. Date: Wed, 09 Apr 1997 15:06:07 -0500
  7. From: Ray Pereda <rpereda@micro.ti.com>
  8. Organization: Texas Instruments
  9. X-Mailer: Mozilla 3.0Gold (X11; I; SunOS 4.1.4 sun4m)
  10. Mime-Version: 1.0
  11. To: Eka Laiman <eka@corp.cirrus.com>
  12. Cc: Kostas Oikonomou <ko@surya.ho.att.com>, icon-group@cs.arizona.edu
  13. Subject: Re: Problem with Icon 9.3
  14. References: <9704082058.AA18878@ss492.corp.cirrus.com>
  15. Content-Type: text/plain; charset=us-ascii
  16. Content-Transfer-Encoding: 7bit
  17. Errors-To: icon-group-errors@cs.arizona.edu
  18. Status: RO
  19. Content-Length: 2489
  20.  
  21. Kka,
  22.  
  23. Indexing table by say an integer is different than indexing by a list. 
  24. An integer is treated like a value.  One integer 3 is the same as
  25. another integer 3.  A list is treated more like an object.  ["q0", "ok"]
  26. could generate a list object in one part of the code.  ["q0", "ok"]
  27. generates an entirely new list in another place in the code.  When a
  28. list a created, an anonymous name or tag is also created.  This
  29. anonymous tag is what is really indexing the table.
  30.  
  31. If you want to index by some value then you need to translate the list
  32. into some unique string, and then use that string to index.
  33.  
  34. What do you think about making tables index-able by either values or
  35. objects?  
  36.  
  37. link ximage
  38. procedure main()
  39.    sd := table([], "object")
  40.    sd[[1]] := 1
  41.    sd[[1]] := 2
  42.  
  43.    every write(ximage(sd))
  44. end
  45.  
  46. would produce
  47.  
  48. T1 := table({L1 := list(0)
  49.       L1})
  50.    T1[{L2 := list(1)
  51.          L2[1] := 1
  52.       L2}] := 1
  53.    T1[{L3 := list(1)
  54.          L3[1] := 1
  55.       L3}] := 2
  56.  
  57. and
  58.  
  59. link ximage
  60. procedure main()
  61.    sd := table([], "value")
  62.    sd[[1]] := 1
  63.    sd[[1]] := 2
  64.  
  65.    every write(ximage(sd))
  66. end
  67.  
  68. T1 := table({L1 := list(0)
  69.       L1})
  70.    T1[{L2 := list(1)
  71.          L2[1] := 1
  72.       L2}] := 2
  73.  
  74.  
  75. -Ray Pereda
  76.  
  77. Eka Laiman wrote:
  78. > > I have the following simple (I think) program:
  79. > >
  80. > > link ximage
  81. > >
  82. > > procedure main()
  83. > >
  84. > >   # The state diagram.
  85. > >   sd := table([])
  86. > >   sd[["q0","ok"]] := "q1"
  87. > >   sd[["q0","nok"]] := "q0"
  88. > >   sd[["q1","nok"]] := "q0"
  89. > >   sd[["q1","ok"]] := "q2"
  90. > >   # q2 is the final state
  91. > >
  92. > >   every x := key(sd) do write(ximage(x), ":", sd[x])
  93. > >
  94. > > end
  95. > >
  96. > > This doesn't behave as I think it should.  The problem seems to be a
  97. > > table whose keys are lists.  Is there something wrong with this kind of
  98. > > structure?  I don't see anything to that effect in the 3d edition of the
  99. > > Icon book, Ch. 6 on tables.
  100. > Wow, indexing using "list"s?
  101. > I do not know if ICON's tables are built with this kind of operation in
  102. > mind. I personally think that ICON tables are like "hash table" where the
  103. > indexing can be done using both "strings" or "integers". According to the
  104. > definition: "Tables resemble lists, except that the keys, or 'subscripts',
  105. > need not be integers but can be *values of any type*." I have not tried to
  106. > do indexing based on "float" yet, although theoretically that's possible
  107. > :-)
  108. > If I were you, I would first convert the list into "string" and use the
  109. > resulting string as the key.
  110. > -eka-
  111.